Hi Tom,
I have one additional suggestion related to this bug. I would introduce this safeguard one level deeper as well, making sure that m_ThreadThatWasLaunched is valid..
Eric
void CKMotionCNCDlg::LogJobEndTime(double seconds)
{
if(m_ThreadThatWasLaunched > -1 && m_ThreadThatWasLaunched < N_USER_GCODE_FILES)
{
CString
File=TheFrame->MainPathRoot+LOG_RUNTIME_FILE,s;
CStdioFile f;
if(f.Open(File, CFile::modeCreate|CFile::modeWrite|CFile::modeNoTruncate))
{
f.SeekToEnd();
CString time = CTime::GetCurrentTime().Format( "%a, %b %d, %Y, %I:%M:%S ");
s.Format("%sElapsed Job Time:%12.1f sec %s\n", time, seconds, FileNames[m_ThreadThatWasLaunched] );
f.WriteString(s);
f.Close();
}
else
{
AfxMessageBox("Unable to open Runtime Log File\r\r" + File);
}
}
}